var filterTypes = {
    0: "Private",
    1: "Shared",
    2: "Standard"
}

var targetTypes = {
    0: "Screening",
    1: "Report"
}

var exportTypes = {
    0: "Excel",
    1: "CSV"
}

var filterStatuses = {
    0: "Draft",
    1: "Active"
}

var collection = db.getSiblingDB("ClientPlatform").Filter;
var bulk = collection.initializeUnorderedBulkOp();
var myDocuments = collection.find({Status: { $type: 16 }}); 
var ops = 0;     
var startDate = new Date();
myDocuments.forEach( 
    function(item){
        item.Type = filterTypes[item.Type];
        item.Status = filterStatuses[item.Status];
        item.TargetType = targetTypes[item.TargetType];
        item.ExportType = exportTypes[item.ExportType];
        
        bulk.find({ _id: item._id }).replaceOne(item);
        
        if ((++ops %1000) === 0){
            bulk.execute();
            bulk = collection.initializeUnorderedBulkOp();
       }
    }
    )
                
bulk.execute();   
var endDate = new Date();
print("\t\t\t" + collection + "\n\nStartDate: " + startDate + "\nEndDate: " + endDate + "\n\n")

